from typing import List


class Solution:
    def numberOfWeakCharacters(self, properties: List[List[int]]) -> int:
        properties.sort(key=lambda x: (x[0], -x[1]), reverse=True)

        ans = 0

        max_defense = 0

        for attack, defense in properties:
            if defense < max_defense:
                ans += 1
            else:
                max_defense = defense

        return ans


if __name__ == "__main__":
    print(Solution().numberOfWeakCharacters(properties=[[5, 5], [6, 3], [3, 6]]))  # 0
    print(Solution().numberOfWeakCharacters(properties=[[2, 2], [3, 3]]))  # 1
    print(Solution().numberOfWeakCharacters(properties=[[1, 5], [10, 4], [4, 3]]))  # 1

    # 自制用例
    print(Solution().numberOfWeakCharacters(properties=[[3, 2], [3, 4], [3, 3]]))  # 0
